package com.neuedu.utils;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidDataSourceFactory;

public class DruidDataSourceUtil {
	 private static DruidDataSource dataSource;

	    static {
	        try {
	            Properties properties = new Properties();
	            properties.load(DruidDataSourceUtil.class.getClassLoader().getResourceAsStream("jdbc.properties"));
	            dataSource = (DruidDataSource) DruidDataSourceFactory.createDataSource(properties);
	        } catch (Exception e) {
	            e.printStackTrace();
	        }
	    }
	    
	    
	    public static Connection getConnection() {
	        try {
	            return dataSource.getConnection();
	        } catch (SQLException e) {
	            e.printStackTrace();
	        }
	        return null;
	    }
	    
	    public static void main(String[] args) {
			System.out.println(getConnection());
		}
}
